function z = g_rb(x)
%Generalized Rosenbrock function(c=100)
%n variable,x0=[-1.2,1,...,-1.2,1]
%fmin1=0 at [1,1,...,1]
%Author:wang zhujun
n=length(x);
% for ii=1:n/2
%     x(2*ii-1)=-1.2;
%     x(2*ii)=1;
% end
z=ones(1,n-1);
for ii=1:n-1
    z(2*ii-1)=10*(x(ii+1)-x(ii)^2);
    z(2*ii)=1-x(ii);
end
z=sum(z.^2);